import dayjs, { ConfigType } from "dayjs";
import isLeapYear from "dayjs/plugin/isLeapYear";
import "dayjs/locale/zh-cn";

dayjs.extend(isLeapYear);
dayjs.locale("zh-cn");

export default function createDayjs(config?: ConfigType) {
  return dayjs(config);
}

export function weekDay(config?: ConfigType) {
  const date = createDayjs(config).day();
  let text;
  switch (date) {
    case 0:
      text = "周日";
      break;
    case 1:
      text = "周一";
      break;
    case 2:
      text = "周二";
      break;
    case 3:
      text = "周三";
      break;
    case 4:
      text = "周四";
      break;
    case 5:
      text = "周五";
      break;
    case 6:
      text = "周六";
      break;
    default:
      text = "";
      break;
  }
  return text;
}
